﻿using Report_IService.Web;
using Report_Service.Web;
using Report_Unity.Basic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;

namespace ReportWebApi.Controllers.Api.WeiXin
{
    [RoutePrefix("api/ItemConfig")]
    public class ItemConfigController : BaseApiController
    {
        private IS_Report_ItemConfigService T_Item_ConfigService = new S_Report_ItemConfigService();

        [HttpPost, Route("AddDept")]
        public ResultInfo AddDept()
        {
            var req = HttpContext.Current.Request;
            string dept_name = req.Form["dept_name"];
            string config_type = req.Form["config_type"];
            string userid = req.Form["userid"];

            ResultInfo res = T_Item_ConfigService.AddDept(dept_name,config_type,userid);
            return res;
        }

        [HttpPost, Route("EditDept")]
        public ResultInfo EditDept()
        {
            var req = HttpContext.Current.Request;
            string id = req.Form["id"];
            string dept_name = req.Form["dept_name"];
            string config_type = req.Form["config_type"];
            string userid = req.Form["userid"];

            ResultInfo res = T_Item_ConfigService.EditDept(id,dept_name,config_type,userid);
            return res;
        }

        [HttpPost, Route("AddItem")]
        public ResultInfo AddItem()
        {
            var req = HttpContext.Current.Request;
            string fid = req.Form["fid"]; // 科室下面的项目
            string item_name = req.Form["item_name"];
            string config_type = req.Form["config_type"];
            string userid = req.Form["userid"];

            ResultInfo res = T_Item_ConfigService.AddItem(fid,item_name,config_type,userid);
            return res;
        }

        [HttpPost, Route("EditItem")]
        public ResultInfo EditItem()
        {
            var req = HttpContext.Current.Request;
            string id = req.Form["id"];
            string item_name = req.Form["item_name"];
            string config_type = req.Form["config_type"];
            string userid = req.Form["userid"];

            ResultInfo res = T_Item_ConfigService.EditItem(id, item_name, config_type, userid);
            return res;
        }

        [HttpPost, Route("DelDeptOrItem")]
        public ResultInfo DelDeptOrItem()
        {
            var req = HttpContext.Current.Request;
            string id = req.Form["id"];
            ResultInfo res = T_Item_ConfigService.DelDeptOrItem(id);
            return res;
        }

        [HttpGet, Route("GetItemConfigType")]
        public ResultInfo GetItemConfigType()
        {
            ResultInfo res = T_Item_ConfigService.GetItemConfigType();
            return res;
        }

        [HttpGet, Route("GetItemConfig")]
        public ResultInfo GetItemConfig()
        {
            ResultInfo res = T_Item_ConfigService.GetItemConfig();
            return res;
        }
    }
}
